
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.AfcRPartyRoleDao;
import com.primeton.eos.oss.model.newdataset.AfcRPartyRole;

@Service
public class AfcRPartyRoleService {

    @Autowired
    private AfcRPartyRoleDao afcRPartyRoleDao;


    public PageResultList<AfcRPartyRole> queryAfcRPartyRolesWithPage(String id,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return afcRPartyRoleDao.queryAfcRPartyRolesWithPage(id,  pageSize, pageIndex);
    }

    public AfcRPartyRole getAfcRPartyRoleById(String id) {
        //TODO 记录日志
        return afcRPartyRoleDao.getEntity(AfcRPartyRole.QNAME, id);
    }

    @Transactional
    public void createAfcRPartyRole(AfcRPartyRole afcRPartyRole) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcRPartyRole.set("createUser", userName);
        afcRPartyRole.set("createTime", new Date());
        afcRPartyRole.set("updateUser", userName);
        afcRPartyRole.set("updateTime", new Date());

        afcRPartyRoleDao.getPrimaryKey(afcRPartyRole);
        afcRPartyRoleDao.insertEntity(afcRPartyRole);
    }
    
    @Transactional
    public void modifyAfcRPartyRole(AfcRPartyRole afcRPartyRole) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcRPartyRole.set("updateUser", userName);
        afcRPartyRole.set("updateTime", new Date());
 
        afcRPartyRoleDao.updateEntity(afcRPartyRole);
    }
    
     @Transactional
    public void removeAfcRPartyRole(AfcRPartyRole[] afcRPartyRole) {
        //TODO 记录日志
        afcRPartyRoleDao.deleteEntity(afcRPartyRole);
    }

}





